package com.xjk.shiro.realms;

import org.apache.shiro.authc.*;
import org.apache.shiro.realm.Realm;

/**
 * @author: XJK
 */

public class MyRealm1 implements Realm {
    @Override
    public String getName() {
        return "我的单Realm配置";
    }

    @Override
    public boolean supports(AuthenticationToken authenticationToken) {
        return authenticationToken instanceof UsernamePasswordToken;
    }

    @Override
    public AuthenticationInfo getAuthenticationInfo(AuthenticationToken authenticationToken) throws AuthenticationException {
        String username = (String) authenticationToken.getPrincipal();// 获取用户名
        String password = String.valueOf((char[])authenticationToken.getCredentials());
        System.out.println(username+"======="+password);
        //如果身份认证验证成功，返回一个AuthenticationInfo实现；
        return new SimpleAuthenticationInfo(username, password, getName());
    }
}
